import axios from 'axios';
import api from 'api/api'

//发送验证码
export function sendCode(phoneNumber){
    let url='/common/sendverifycode';
    let data={
        mobile:phoneNumber
    }
    return api.post(url,data);
}

//用户登录
export function login(username,password){
    let url='/member/login';
    let data={
        username:username,
        password:password,
        gameId:41
    }
    return api.get(url, {params: data});
}
//用户注册
export function userReg(type,phoneNumber,username,password,verifyCode){
    let url='/member/reg';
    let data={
        type:type,
        mobile:phoneNumber,
        username:username,
        password:password,
        verifyCode:verifyCode,
        gameId:41
    }
    return api.post(url,data);
}
//找回密码
export function retrievePassword(phone,code,password_new){
    let url='/sdk/retrieve-password';
    let data={
		phone:phone,
		password_new:password_new,
		code:code
    }
    return api.post(url,data);
}

//检测手机号是否存在
export function checkphone(phone,type){
    let url='/member/phone';
    let data={
		phone:phone,
		type:type,
    }
    return api.get(url, {params: data});
}

//退出登录
export function logOut(){
    let url='/member/logout';
    let data={
        gameId:41
    }
    return api.get(url,{params: data});
}
//用户登录状态
export function logStatus(){
    let url='/member/loginstat';
    return api.get(url);
}
//解绑绑定
export function bindPhone(phone,verifyCode,difference){
    let url='/sdk/binding-phone';
    let data={
		phone:phone,
		verifyCode:verifyCode,
		difference:difference
    }
    return api.post(url,data);
}
//验证手机号和验证码是否匹配
export function checkCode(phone,verifyCode){
    let url='/sdk/validate-phone';
    let data={
		phone:phone,
		verifyCode:verifyCode,
    }
    return api.post(url,data);
}

//实名认证
export function checkAuth(username,realName,idCard){
    let url='/sdk/auth';
    let data={
		username:username,
		realName:realName,
		idCard:idCard
    }
    return api.post(url,data);
}

//修改密码
export function editPassword(password,password_new){
    let url='/sdk/edit-password';
    let data={
		password:password,
		password_new:password_new,
    }
    return api.post(url,data);
}
//支付宝登录
export function zfbLogin(auth_code,gameId){
    let url='/member/ali';
    let data={
        auth_code:auth_code,
        gameId:41
    }
    return api.get(url,{params: data});
}
//微信登录
export function wxlogin(code){
    let url='/member/third-login';
    let data={
        code:code,
        site:2,
        gameId:41
    }
    return api.get(url,{params: data});
}